/**
 * 作者：陈文斌 on 2019/1/17.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/model/Company/company_info_model.dart';
import 'package:crm/viewModel/ClientManager/client_manager_view_model.dart';

class ImportClientListRow extends StatelessWidget {
  final VoidCallback onTap;
  final CompanyInfoModel client;
  final bool isSelect;

  ImportClientListRow({
    Key key,
    this.onTap,
    this.client,
    this.isSelect = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    CompanyInfoModel _client = client ?? CompanyInfoModel.fromJson({});

    String _statusImage;
    switch(ClientManagerVM.getVerifyStatus(client)) {
      case 0: _statusImage = 'images/ic_shop_search.png';break;
      case 1: _statusImage = 'images/ic_business_search.png';break;
      default: _statusImage = 'images/ic_shop_search.png';
    }

    return Material(
      color: Colors.white,
      child: InkWell(
        onTap: onTap,
        child: Container(
          width: MediaQuery.of(context).size.width,
          height: 60,
          padding: EdgeInsets.only(left: 16),
          child: Column(
            children: <Widget>[
              Expanded(
                child: Padding(
                  padding: EdgeInsets.fromLTRB(0, 7, 16, 7),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Container(
                        width: 18,
                        height: 18,
                        margin: EdgeInsets.only(left: 12, right: 12),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(9),
                          border: Border.all(width: 1.5,color: isSelect ? Colors.transparent : AppColors.LineColor),
                        ),
                        child: isSelect ? Image.asset(
                          'images/ic_selected_setting.png',
                          fit: BoxFit.fill,
                        ) : Container(),
                      ),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Container(
                                constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width - 32 - 24 - 18 - 30 - 6),
                                child: Text(
                                  _client.Name ?? '',
                                  style: TextStyle(
                                    color: AppColors.TextColor,
                                    fontSize: AppFontSizes.Font15,
                                    fontFamily: AppFontFamilies.PingFangSC,
                                    fontWeight: FontWeight.w700,
                                  ),
                                  overflow: TextOverflow.ellipsis,
                                  maxLines: 1,
                                ),
                              ),
                              Padding(padding: EdgeInsets.only(left: 6)),
                              Container(
                                width: 30,
                                height: 16,
                                padding: EdgeInsets.all(1),
                                child: Image.asset(_statusImage),
                              ),
                            ],
                          ),
                          Padding(padding: EdgeInsets.only(top: 7)),
                          Container(
                            constraints: BoxConstraints(
                              maxWidth: MediaQuery.of(context).size.width - 32 - 24 - 18,
                            ),
                            child: Text(
                              ClientManagerVM.getSubTitle(_client) ?? '',
                              style: TextStyle(
                                color: AppColors.PlaceholderTextColor,
                                fontSize: AppFontSizes.Font12,
                                fontFamily: AppFontFamilies.PingFangSC,
                                fontWeight: FontWeight.w500,
                              ),
                              overflow: TextOverflow.ellipsis,
                              maxLines: 1,
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
              ),
              Container(
                height: 1,
                color: AppColors.LineColor,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
